package wh;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Vector;

import wh.guistuff.MyTableDataModel;
import wh.iolists.OrderList;
import wh.iolists.StorageDiskList;
import wh.products.StorageDisk;

public class TableDataHandler {

	public void populateOrderTable(MyTableDataModel tableModel, OrderList allOrders)
    {
    	int orderSize = allOrders.getOrderListSize();
    	Vector<String> rowData = null;
    	
    	for (int i = 0; i < orderSize; i++)
    	{
    		Order order = allOrders.getOrder(i);
    		
    		rowData = new Vector<String>();
      		rowData.addElement(order.getOrderID());
      		rowData.addElement(order.getCustomerID());
      		rowData.addElement(order.getProductID());
      		rowData.addElement(String.valueOf(order.getQuantity()));
      		
      		tableModel.addRow(rowData);
    	}
    }
	
	public void populateWarehouseTable(MyTableDataModel whModel, StorageDiskList allProducts)
    {
		Iterator<Entry<String, StorageDisk>> it = allProducts.getIterator();
    	
    	Vector<String> rowData = null;
    	
    	while (it.hasNext()) {
    		
    		Entry<String, StorageDisk> pairs = it.next();
    		
    		StorageDisk disk = pairs.getValue();
    	    
    		rowData = new Vector<String>();
      		rowData.addElement(disk.getProductID());
      		rowData.addElement(disk.getProductname());
      		rowData.addElement(String.valueOf(disk.getPrice()));
      		rowData.addElement(String.valueOf(disk.getInStock()));
      		
      		whModel.addRow(rowData);
    	}
    }
}
